package com.salts.service.Impl;

import com.salts.Dao.UserInfoMapper;
import com.salts.domain.dto.Result;
import com.salts.domain.po.UserInfo;
import com.salts.service.LogInService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LogInServiceImpl implements LogInService {

    @Autowired
    UserInfoMapper userInfoMapper;

    /**
     * @param wxOpenId
     * @return
     */
    @Override
    public UserInfo selectByid(String wxOpenId) {
        return userInfoMapper.selectByOpenId(wxOpenId);
    }

    /**
     * @param username
     * @param avatar
     * @param wxOpenId
     * @return
     */
    @Override
    public Result insertWxUser(String username, String avatar, String wxOpenId) {
        Integer i = userInfoMapper.insertWxUser(username, avatar, wxOpenId);
        return Result.ok(i>0);
    }

    /**
     * @param username
     * @param avatar
     * @param wxOpenId
     * @return
     */
    @Override
    public Result updateWxUser(String username, String avatar, String wxOpenId) {
        return Result.ok(userInfoMapper.updateWxUser(username,avatar,wxOpenId)>0);
    }
}
